<?php
include_once('./header.php');
?>
				<div id="corps-grand">
					<div id="tete-corps-grand"></div>
					<div id="milieu-corps-grand">
						<h2><img src="./theme/avatar/wolf_decal.png" alt="FRLB Loup Blanc">[FRLB] Loup Blanc en live</h2>
						<br>
						<br>
						<?php
						$channels = 'lamodes,lePETITfranais,p4lmeza,stakaros' ;
						$dataArray = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams?channel=' . $channels), true);

						if( $dataArray['_total'] > 0 ) {
							foreach($dataArray['streams'] as $mydata) {
								if($mydata['game'] != null ) {
									if( $mydata['game'] == 'PlanetSide 2' ) {
										echo '<img src="./theme/images/online.gif" alt="En ligne" /> ' . $mydata['channel']['display_name'] . ' (' . $mydata['viewers'] . ' spectateur' . AuPluriel($mydata['viewers']) .')<br>
										<iframe src="http://www.twitch.tv/' . $mydata['channel']['display_name'] . '/embed" frameborder="0" scrolling="no" height="378" width="620"></iframe><a href="http://www.twitch.tv/' . $mydata['channel']['display_name'] . '?tt_medium=live_embed&tt_content=text_link" style="padding:2px 0px 4px; display:block; width:345px; font-weight:normal; font-size:10px;text-decoration:underline;">Regarder la vidéo de ' . $mydata['channel']['display_name'] . ' en direct sur www.twitch.tv</a><br></li>';
									}
									else {
										echo $mydata['channel']['display_name'] . 'joue à un autre jeu.';
									}
								}
								else {
									echo '<img src="./theme/images/offline.gif" alt="Hors ligne" />';
								}
							}
						}
						else{
							echo '<h3>Pas de live</h3>(La page se rafraichi toutes les 5 minutes)';
							?>
							<script type="text/javascript">
							function refresh(time) {
								setTimeout(function () { window.location.reload(); }, time*1000);
							}
							refresh(5*60); // Rafraichit la page toutes les 5 minutes
							</script>
							<?php
						}
						?>
					</div>
					<div id="pied-corps-grand"></div>
				</div>
				<br class="clear" /> 
<?php
include_once('./footer.php');
?>